package at.newmedialab.test.config

/**
 * Add file description here! 
 *
 * User: sschaffe
 */

import at.newmedialab.test.base.WebserviceBaseTest
import org.junit.Test

class ConfigTest extends WebserviceBaseTest {


    @Test public void setConfig() {
        def specs =
        [
            // send first a POST setting the key 'key.test' to 'Test'
            [
                    'method'  : 'POST',
                    'path'    : 'core/config/data/key.test',
                    'request' : [
                            'body'    : '["Test"]'
                    ],
                    'response' : [
                            'code'    : 200,
                    ]

            ],
            // then query for the key and check whether it has the right value
            [
                    'method'  : 'GET',
                    'path'    : 'core/config/data/key.test',
                    'request' : [
                          'headers' : ['Accept'    : 'application/json']
                    ],
                    'response' : [
                            'code'    : 200,
                            'body'    : /Test/
                    ]

            ],
            // then delete the key again
            [
                    'method'  : 'DELETE',
                    'path'    : 'core/config/data/key.test',
                    'request' : [
                            'headers' : ['Accept'    : 'application/json']
                    ],
                    'response' : [
                            'code'    : 200,
                    ]

            ],
            // then query for the key and check whether it is deleted
            [
                    'method'  : 'GET',
                    'path'    : 'core/config/data/key.test',
                    'request' : [
                          'headers' : ['Accept'    : 'application/json']
                    ],
                    'response' : [
                            'code'    : 404,
                    ]

            ],


        ]

        specs.each { spec-> process(spec) }
    }

}